﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Gqq.Csharpindepth.Designpatter
{
    public class BuildHotelDirector
    {
        /// <summary>
        /// 在构造函数中，赋予BuildHotelClass类型参数的值
        /// </summary>
        /// <param name="buildHotelClass"></param>
        public BuildHotelDirector(BuildHotelClass buildHotelClass)
        {
            _build = buildHotelClass;
        }

        private readonly BuildHotelClass _build;

        public void Dobuild()
        {
            _build.BuildDiji();
            _build.BuildWall();
            _build.BuildTianhuaban();
            _build.BuildZhuangxiu();
        }

        /// <summary>
        /// 生成器模式测试
        /// </summary>
        public static void BuildPatternTest()
        {
            BuildHotelDirector bd = new BuildHotelDirector(new GqqBuildClass());
            bd.Dobuild();
            
            bd = new BuildHotelDirector(new QitaBuildClass());

            bd.Dobuild();
            //很明显，抽象类不能被实例化，所以避免了无法调用方法的情况。
//            new BuildHotelClass();

        }
    }
}
